﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TaobaoERP.BusinessTaobao.Common;
using TaobaoERP.Entity;
using TaobaoERP.BusinessTaobao.ParObject;
using System.Collections.Specialized;
using TaobaoERP.Core.Common;

namespace TaobaoERP.BusinessTaobao.TaobaoAPI
{
    public class ItemCatsAPI 
    {
        /// <summary>
        /// 商品的标准商品类目。
        /// </summary>
        /// <returns></returns>
        [AlisoftAPI(apiType = 2, apiname = "apiname")]
        public List<ItemCat> itemcats_get(int parent_cid)
        {
            ItemCatsGetPar par = new ItemCatsGetPar();
            par.parent_cid = parent_cid;
            par.sip_sessionid = Utils.GetCookies("sessionid");
            return APIUtils.Result<List<ItemCat>>(par, (string result) =>
            {
                NameValueCollection ResultPar = new NameValueCollection();
                ResultPar.Add("ID", "cid");
                ResultPar.Add("Name", "name");
                ResultPar.Add("ParentID", "parent_cid");
                ResultPar.Add("IsParent", "is_parent");
                return new XmlHandler<ItemCat>().ListItemByXml(result, "rsp/item_cat", ResultPar);
            });
        }

        /// <summary>
        /// 卖家自定义商品类目。
        /// </summary>
        /// <param name="Nick"></param>
        /// <returns></returns>
        public List<SellerCat> sellercats_list_get(string Nick)
        {
            SellerCatsListPar parSL = new SellerCatsListPar();
            parSL.sip_sessionid = Utils.GetCookies("sessionid"); ;
            parSL.nick = Nick;
            return APIUtils.Result<List<SellerCat>>(parSL, (string result) =>
            {
                NameValueCollection par = new NameValueCollection();
                par.Add("Cid", "cid");
                par.Add("Name", "name");
                par.Add("ParentID", "parent_cid");
                return new XmlHandler<SellerCat>().ListItemByXml(result, "rsp/seller_cat", par);
            });
        }
    }
}
